package summer.hash;

import java.util.HashMap;

public class Solution454 {
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int value : nums1) {
            for (int i : nums2) {
                map.put(value + i, map.getOrDefault(value + i, 0) + 1);
            }
        }
        int res = 0;
        for (int k : nums3) {
            for (int i : nums4) {
                int cur = k + i;
                res += map.getOrDefault(0 - cur, 0);
            }
        }
        return res;
    }
}
